<template>
  <div class="dashboard-editor-container">

    <panel-group @handleSetLineChartData="handleSetLineChartData"/>

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData"/>
    </el-row>

    <el-row :gutter="32">
      <!--      <el-col :xs="24" :sm="24" :lg="8">-->
      <!--        <div class="chart-wrapper">-->
      <!--          <raddar-chart />-->
      <!--        </div>-->
      <!--      </el-col>-->
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-wrapper">
          <!-- 饼图 -->
          <pie-chart :chart-data="pieChartData"/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-wrapper">
          <!-- 柱状图 -->
          <bar-chart :chart-data="barChartData"/>
        </div>
      </el-col>
    </el-row>

  </div>
</template>

<script>
import PanelGroup from './PanelGroup.vue'
import LineChart from './LineChart.vue'
import RaddarChart from './RaddarChart.vue'
import PieChart from './PieChart.vue'
import BarChart from './BarChart.vue'

//曲线图-数据
const lineChartData = {
  //省：
  newVisitis: {
    expectedData: [1, 2, 0, 1, 1],        //超载
    actualData: [9, 9, 8, 9, 8],          //临界
    surplusData: [24, 23, 26, 24, 25]    //盈余
  },
  //市：
  messages: {
    expectedData: [10, 3, 2, 5, 3],           //超载
    actualData: [80, 82, 81, 79, 78],         //临界
    surplusData: [203, 208, 210, 209, 212]    //盈余
  }
}

//饼图-数据
const pieChartData = {
  //省：
  newVisitis: {
    pieData: [{value: 1, name: '超载区'}, {value: 9, name: '临界区'}, {value: 24, name: '盈余区'}]
  },
  //市：
  messages: {
    pieData: [{value: 10, name: '超载区'}, {value: 80, name: '临界区'}, {value: 203, name: '盈余区'}]
  }
}

//柱状图-数据
const barChartData = {
  //省：
  newVisitis: {
    expectedData: [1, 2, 0, 1, 1],        //超载
    actualData: [9, 9, 8, 9, 8],          //临界
    surplusData: [24, 23, 26, 24, 25]    //盈余
  },
  //市：
  messages: {
    expectedData: [10, 3, 2, 5, 3],           //超载
    actualData: [80, 82, 81, 79, 78],         //临界
    surplusData: [203, 208, 210, 209, 212]    //盈余
  }
}

export default {
  name: 'Index',
  components: {
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      pieChartData: pieChartData.newVisitis,
      barChartData: barChartData.newVisitis
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type],
        this.pieChartData = pieChartData[type],
        this.barChartData = barChartData[type]
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
